<template>
	<view>
		<u-modal :show="showModal"  :closeOnClickOverlay="true" :showCancelButton="true" @confirm="confirm" @cancel="cancel" @close="close">
			<view class="slot-content">
				<view v-for="(item,index) in list">
					{{item.name}}
					<u-input border="bottom" clearable placeholder="" style="margin-bottom: 10%;" v-model="item.value" :type="item.inputType">
						<template slot="suffix">
							{{item.suffix}}
						</template>
					</u-input>
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	export default {
		name:"umodal",
		 props: {
			show: {
				type: Boolean,
				value: false
			},
			arrayList:{
				type:Array,
				value:[{
					name:'',
					value:'',
					suffix:''
				}]
			}
		},
		watch:{
			show(){
				this.showModal=this.show
			},
			arrayList(){
				this.list=this.arrayList
			}
		},
		data() {
			return {
				showModal:this.show,
				name:'',
				number:'',
				list:this.arrayList,
			};
		},
		methods:{
			confirm(){
				for(let i=0 ;i<this.list.length;i++){
					if(this.list[i].value == ''){
						this.$utils.errorMsg("字段都不允许为空")
						return
					}
				}
				this.showModal=false
				let pests = [this.list,this.showModal]
				this.$emit("confirm",pests)
			},
			cancel(){
				this.showModal=false
				this.$emit("cancel",this.showModal)
			},
			close(){
				this.showModal=false
				this.$emit("close",this.showModal)
			}
		}
	}
</script>

<style>

</style>
